/**
 * com.cnhis.his.customer.service.Rac1Service.java
 */
package com.mbmed.doctor.homepage.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.homepage.bo.Rac1Bo;
import com.mbmed.doctor.homepage.bo.Rad1Bo;
import com.mbmed.doctor.homepage.mapper.Rac1;
import com.mbmed.doctor.homepage.mapper.Rad1;

/**
 * @file  Rac1Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Rac1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-10-15 05:13:24
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/rac1")
@Component
public class Rac1Service {
	
	private static Logger logger = Logger.getLogger(Rac1.class);
	
	@Autowired
	private Rac1Bo rac1Bo;
	
	@Autowired
	private Rad1Bo rad1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Rac1> getAll() throws Exception{
        List<Rac1> list = new ArrayList<Rac1>();
        return rac1Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Rac1 getRac1(@PathParam("id") String id) throws Exception{
    	Rac1 rac1 = null;
    	return rac1Bo.get(id);        
    }
	
	
	
	/**
     * 查询病案分娩详情
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("/getmedrecrac1byvae01")
	@Produces({MediaType.APPLICATION_JSON})
    public Rac1 getMedRecRac1ByVae01(@QueryParam("vae01") java.lang.String vae01) throws Exception{
		Rac1 rac1 = null;
		rac1 = rac1Bo.getMedRecRac1ByVae01(vae01);
		
		if(null == rac1){
			return null;
		}
		
		List<Rad1> rad1List = new ArrayList<Rad1>();
		rad1List = rad1Bo.getRad1ByVae01(vae01);
		if(!(null==rad1List)){
			rac1.setRad1List(rad1List);
		}
    	return rac1;
	}
	
	
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Rac1 saveRac1(
			@FormParam("vaa07") java.lang.Integer vaa07,
			@FormParam("rac01") java.util.Date rac01,
			@FormParam("rac02") java.lang.Integer rac02,
			@FormParam("rac03") java.lang.Integer rac03,
			@FormParam("rac04") java.lang.Integer rac04,
			@FormParam("rac05") java.lang.Integer rac05,
			@FormParam("rac06") java.lang.Integer rac06,
			@FormParam("rac07") java.lang.String rac07,
			@FormParam("rac08") java.lang.String rac08,
			@FormParam("rac09") java.lang.String rac09,
			@FormParam("rac10") java.lang.String rac10,
			@FormParam("rac11") java.math.BigDecimal rac11,
			@FormParam("rac13") java.lang.Byte rac13,
			@FormParam("rac14") java.lang.Byte rac14,
			@FormParam("rac15") java.lang.Byte rac15,
			@FormParam("rac16") java.lang.Byte rac16,
			@FormParam("rac17") java.lang.Byte rac17,
			@FormParam("rac18") java.lang.Integer rac18,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Rac1 rac1 = new Rac1();
		rac1.setVaa07(vaa07);
		rac1.setRac01(rac01);
		rac1.setRac02(rac02);
		rac1.setRac03(rac03);
		rac1.setRac04(rac04);
		rac1.setRac05(rac05);
		rac1.setRac06(rac06);
		rac1.setRac07(rac07);
		rac1.setRac08(rac08);
		rac1.setRac09(rac09);
		rac1.setRac10(rac10);
		rac1.setRac11(rac11);
		rac1.setRac13(rac13);
		rac1.setRac14(rac14);
		rac1.setRac15(rac15);
		rac1.setRac16(rac16);
		rac1.setRac17(rac17);
		rac1.setRac18(rac18);

		return rac1 = rac1Bo.save(rac1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeRac1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return rac1Bo.remove(id);

	}
	
}
